import axios from '@/utils/request'
const base = '/movieserver'

export function listAppPackages(params) {
  return axios({
    url: `${base}/appPackages`,
    method: 'get',
    params: params
  })
}

export function saveAppPackages(data) {
  return axios({
    url: `${base}/appPackages`,
    method: 'post',
    data
  })
}

export function saveAppPackageItem(data) {
  return axios({
    url: `${base}/appPackageItems`,
    method: 'post',
    data
  })
}

export function uploadFile(id, data) {
  return axios({
    url: `${base}/appPackageItems/` + id + `/file`,
    method: 'post',
    data,
    timeout: 3600000
  })
}

export function uploadPackageFiles(reqs) {
  return axios.all(reqs)
}

export function appPackageFileItems(id) {
  return axios.get(`${base}/appPackages/` + id + `/files`)
}

export function downloadAppPackage(id) {
  return axios.get(`${base}/appPackages/` + id + `/zip`, { responseType: 'arraybuffer', timeout: 3600000 })
}

export function setAppPackageLatest(id) {
  return axios({
    url: `${base}/appPackages/` + id,
    method: 'put'
  })
}

export function deleteAppPackage(id) {
  return axios({
    url: `${base}/appPackages/` + id,
    method: 'delete'
  })
}
